package day08;

import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 使用异常捕获完成下述操作
 * 将控制台输入的每一行字符串使用缓冲字符输出流PrintWriter
 * 按行以GBK编码写入到文件note.txt中
 * @author Bonnie
 *
 */
public class Test02 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        try (PrintWriter pw = new PrintWriter("note.txt","GBK")) {
            String str;
            while (!"exit".equals(str = input.nextLine())){
                pw.println(str);
            }
            System.out.println("运行完毕");
        } catch (FileNotFoundException | UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        input.close();
    }
}
